<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<div class="main-content">
    <div class="box box-main">
        <form id="flowForm" model="post" action="<c:url value="/web/admin/auditFlow/addOrUpdate.action"/>"
              method="post" class="form-horizontal">
            <div class="box-body">
                <div class="form-unit">基本信息</div>
                <input type="hidden" name="id" value="${auditFlow.id}"/>
                <input type="hidden" name="flow" value='${auditFlow.flow}'/>
                <input type="hidden" name="createDate" value="<fmt:formatDate value="${auditFlow.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/>"/>
                <div class="row">
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required">*</span>名称：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="flowName" name="flowName" value="${auditFlow.flowName}"
                                       class="form-control required">
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required">*</span>应用：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <input path="select_application" id="select_application" name="select_application"
                                       class="form-control required">
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required ">*</span> 默认审批流：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <select id="sex" name="defaultV" class="form-control required">
                                    <option value="false" selected>否</option>
                                    <option value="true" <c:if test="${auditFlow.defaultV==true}">selected</c:if>> 是</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12">
                        <div class="form-group">
                            <label class="control-label col-sm-4" title="">
                                <span class="required">*</span>审批操作：<i class="fa icon-question hide"></i></label>
                            <div class="col-sm-8">
                                <div class="ibox tabs-container ibox-content">
                                    <label class="radio-inline">
                                        <input type="radio"  <c:if test="${type=='COMPLETE'}">checked</c:if> value="complete" id="complete" name="auditType" >完成操作</label>
                                    <label class="radio-inline">
                                        <input type="radio" value="delay" <c:if test="${type=='DELAY'}">checked</c:if> id="delay" name="auditType">延期操作</label>
                                    <label class="radio-inline">
                                        <input type="radio" value="cancel" id="cancel" <c:if test="${type=='CANCEL'}">checked</c:if> name="auditType">取消操作</label>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="box-footer">
                <div class="row">
                    <div class="col-sm-offset-2 col-sm-10">
                        <button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i>
                            保 存
                        </button>&nbsp;

                        <button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="closeView()"><i
                                class="fa fa-times"></i> 关 闭
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    $("#flowForm").validate({
        submitHandler: function (form) {
            if (!validateMagicSuggest({
                select_application: '不能为空'
            })) return false;
            js.ajaxSubmitForm($(form), function (data) {
                js.showMessage(data.msg);
                if (data.status == Global.NO) {
                    closeView();
                    $('#auditFlowGrid').dataGrid("refresh");
                }
            }, "json");
        }
    });
    <%--var select_enterprise = $('#select_enterprise').magicSuggest({--%>
        <%--allowFreeEntries: false,--%>
        <%--data: '<c:url value="/web/admin/enterprise/getEnterpriseListMagic.action?id=${auditFlow.enterprise.id}" />',--%>
        <%--queryParam: 'q',--%>
        <%--valueField: "value",--%>
        <%--displayField: "text",--%>
        <%--maxSelection: 1,--%>
        <%--noSuggestionText: '',--%>
        <%--placeholder: '请选择',--%>
        <%--required: true,--%>
        <%--autoSelect: true,--%>
        <%--selectFirst: true,--%>
        <%--value: magicSuggestValue('${auditFlow.enterprise.id}')--%>
    <%--});--%>

    var select_application = $('#select_application').magicSuggest({
        allowFreeEntries: false,
        data: '<c:url value="/web/admin/application/getApplicationListMagic.action?id=${auditFlow.applicationModule.id}" />',
        queryParam: 'q',
        valueField: "value",
        displayField: "text",
        maxSelection: 1,
        noSuggestionText: '',
        placeholder: '请选择',
        required: true,
        autoSelect: true,
        selectFirst: true,
        value: magicSuggestValue('${auditFlow.applicationModule.id}')
    });
    $(select_application).on('selectionchange', function(e,m){
        validateMagicReload();
    });


    function closeView() {
        layer.close(LayWin['wAuditFlow']);
    }
</script>


